﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zss.aspx.cs" Inherits="Cn.Cellula.Website.Test.zss" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        table{}
        TD
        {
            font-size:11px;
            }
        div
        {
            width:60px;
            cursor:pointer;
            }
    </style>
    <script type="text/javascript" src="/jskit.org/JskitLoad.js"></script>
    <script type="text/javascript" src="/jskit.org/server/JskitXmlHttp.js"></script>
    <script type="text/javascript">
        var timer = null;
        var time_count = 0;
        var mtype = 0;
        var mbtn = null;
        function LoadData(rType, rBtn) {
            mtype = rType;
            mbtn = rBtn;
            $("#displayer").innerHTML = "数据加载中...";
            ShowWaiting();
            mbtn.disabled = true;
            var requestUrl = (mtype == 0) ? "_zss.aspx?t=html" : "_zss.aspx?t=json";
            var ajax = new JskitXmlHttpAction(requestUrl+"&=" + jskitUtil.guid(), "loadDataCallback", "text");
        }
        function ShowWaiting() {
            time_count++;
            $("#time_clock").innerHTML = time_count;
            timer = setTimeout(ShowWaiting, 1000);
        }
        function loadDataCallback(data) {
            clearInterval(timer);
            timer = null;
            mbtn.disabled = false;
            if (mtype == 0) {
                $("#displayer").innerHTML = data;
            } else {
                $("#displayer").innerHTML = drawList(data);
            }
        }
        function drawList(rData) {
            var data = null;
            eval("data = "+rData+";");
            var str = new Array();
            str.push('<table border="1">');
            for (var i = 0; i < data.length; i++) {
                str.push('<tr>');
                for (var j = 0; j < data[i].length; j++) {
                    str.push('<td><div name="cell" onmouseup="ShowCell(this)">' + data[i][j] + '</div></td>');
                }
                str.push('</tr>');
            }
            str.push('</table>');
            return str.join('');
        }
        var cell = null;
        var textinput = null;
        function ShowCell(rTd) {
            if (rTd.childNodes[0]!=null && rTd.childNodes[0].tagName == "INPUT") return false;
            UnShowCell();
            cell = rTd;
            if (textinput == null) {
                textinput = document.createElement("input");
            }
            textinput.style.display = "block";
            textinput.style.width = cell.offsetWidth + "px";
            var val = cell.innerHTML;
            textinput.value = val;
            cell.innerHTML = "";
            cell.appendChild(textinput);

            cell.style.border = "1px solid #ffff00";
        }
        function UnShowCell() {
            if (cell != null) {
                cell.style.border = "0px solid #ffffff";
            }
            if (textinput != null) {
                if (cell != null) {
                    $("body").appendChild(textinput);
                    cell.innerHTML = textinput.value;
                }
                textinput.value = "";
                textinput.style.display = "none";
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="time_clock">0</div>
    <input type="button" id="btn_load" onclick="LoadData(0,this)" value="加载HTML" />
    <input type="button" id="Button1" onclick="LoadData(1,this)" value="加载JSON" />
    <div id="displayer">
        
    </div>
    </form>
</body>
</html>
